//
//  CacheManager.swift
//  Motion
//
//  Created by 悦月越悦 on 2021/3/25.
//

import Foundation

struct CacheManager {
    var root : URL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
                                .appendingPathComponent(
                                        "Motion",
                                        isDirectory: false
                                )
    func clearVideoCache(){
        do {
            let fileManager = FileManager.default

            print(root.path)
            // Check if file exists
            if fileManager.fileExists(atPath: root.path) {
                // Delete file
                try fileManager.removeItem(atPath: root.path)
            } else {
                print("File does not exist")
            }
        } catch {
            print("An error took place: \(error)")
        }
    }
}
